package com.sf.hackathons.app.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sf.hackathons.app.R;
import com.sf.hackathons.app.bean.StoreUserBean;
import com.sf.hackathons.app.utils.CommUtils;
import com.sf.hackathons.lib.ui.CircleImageView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chengzi on 2017/12/15.
 * 水平listView
 */

public class HorPersonAdapter extends BaseAdapter

{
    List<StoreUserBean> mPersonList = new ArrayList<>();
    private LayoutInflater inflater;
    private Context mContext;
    StoreUserBean mOrgDocDetailBean;

    public HorPersonAdapter(Context context, List<StoreUserBean> mPersonList) {
        this.mContext = context;
        this.inflater = LayoutInflater.from(context);
        this.mPersonList = mPersonList;
    }

    @Override
    public int getCount() {

        return mPersonList.size();
    }


    @Override
    public Object getItem(int position) {
        return this.mPersonList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        mOrgDocDetailBean = mPersonList.get(position);
        if (convertView == null) {
            holder = new ViewHolder();


            convertView = inflater.inflate(R.layout.item_hor_listview_person, null);

            holder.mImageView = (CircleImageView) convertView.findViewById(R.id.mCircleImage);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        CommUtils.loadImage(this.mContext, holder.mImageView, mOrgDocDetailBean.getPhotoUrl());

        return convertView;
    }

    class ViewHolder {
        public CircleImageView mImageView;
    }
}
